package com.pdh.file.controller;

import com.pdh.file.entity.Result;
import com.pdh.file.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: 彭_德华
 * @Date: 2021-10-20 16:38
 */
@Api(description = "文件上传接口")
@RestController
public class UploadController {

    // 加上注解测试

    @Autowired
    private UploadService uploadService;

    @Operation(summary = "单个/多个 文件上传到本地")
    @PostMapping(value = "/uploadFileToLocal" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result uploadFileToLocal(@RequestPart("files") MultipartFile[] files){
        return uploadService.uploadFileToLocal(files);
    }

    @Operation(summary = "多个/单个 文件上传到七牛云")
    @PostMapping(value = "/uploadMultiFileToQiniu" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result uploadMultiFileToQiniu(@RequestPart("files") MultipartFile[] files){
        return uploadService.uploadFileToQiniu(files);
    }
}
